package me.pearjelly.pmc.web;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import me.pearjelly.pmc.util.Pagination;

import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3076915268236799804L;
	
	private String message;

	private Pagination pagination;
	private int status = 1;


	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Pagination getPagination() {
		return pagination;
	}

	public void setPagination(Pagination pagination) {
		this.pagination = pagination;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

    public HttpServletRequest getRequest() {
        return org.apache.struts2.ServletActionContext.getRequest();
    }
    
    @SuppressWarnings("unchecked")
	public void saveMessage(String msg) {
        List<String> messages = (List<String>) getRequest().getSession().getAttribute("messages");
        if (messages == null) {
            messages = new ArrayList<String>();
        }
        messages.add(msg);
        getRequest().getSession().setAttribute("messages", messages);
    }
}
